<template>
	<view>
		<u-cell-group><u-cell-item icon="setting" :title="doWhat" @click="Loose"></u-cell-item></u-cell-group>
	</view>
</template>

<script>
export default {
	onLoad(cardId) {
		this.card.id = cardId.id;
		this.$axios({
			method: 'post',
			url: '/api/card/getById',
			data: this.card
		}).then(r => {
			if (r.data.code == 200) {
				this.card = r.data.data;
				this.doWhat = this.card.cardStatus == 'y' ? '快速挂失' : '解除挂失';
			}
		});
	},
	data() {
		return {
			doWhat: null,
			card: {
				id: null,
				cardNum: null,
				cardMoney: null,
				student: {
					studentNumber: null,
					name: null
				}
			}
		};
	},
	methods: {
		Loose() {
			this.card.cardStatus = this.card.cardStatus == 'y' ? 'n' : 'y'
			this.$axios({
				method: 'post',
				url: '/api/card/update',
				data: this.card
			}).then(r => {
				if (r.data.code == 200) {
					let tip=this.card.cardStatus=='n'?"挂失成功":"已经解除挂失"
					uni.showToast({
						icon: 'success',
						title: tip,
					});
				}
			});
		}
	}
};
</script>

<style></style>
